<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>组织积分申请</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#checkAll").on('click', function() {
				//复选框
				var ch = this.checked;
				if (ch) {
					$("input[name='ids']").prop("checked", true);
				} else {
					$("input[name='ids']").prop("checked", false);
				}
			});
			getCheckList = function() {
				var ids = [];
				$("input[name='ids']:checked").each(function() {
					ids.push($(this).val());
				});
				return ids;
			}
			getCheckListState = function() {
				var states = [];
				$("input[name='ids']:checked").each(function() {
	    			var state=$(this).parent().parent().children("td").eq(3).children("input").eq(0).val();	
	    			states.push(state);
				});
				return states;
			}
			//新增
			$("#btnAdd").click(function(){
				
				$.ajax({
					type : 'POST',
					url : "${ctx}/life/organizeLife/checkOrgSatate",
					type : "get",
					dataType : "json",
					async : false,//同步  
					success : function(result) {		
						if(result.type == "success"){
							$("#searchForm").attr("action","${ctx}/life/organizascore/form");
							$("#searchForm").submit();
						} else {
							top.$.jBox.error("当前支部未开通！","系统提示",function(v,h,f){
							
							},{buttonsFocus:1});
							top.$('.jbox-body .jbox-icon').css('top','55px');
														
						}
					}
				});	
			});
			//提交			
			$("#btnTj").on('click', function() {
				
				$.ajax({
					type : 'POST',
					url : "${ctx}/life/organizeLife/checkOrgSatate",
					type : "get",
					dataType : "json",
					async : false,//同步  
					success : function(result) {		
						if(result.type == "success"){
							var ids = getCheckList();
							var states=getCheckListState();
							if (ids.length < 1) {
								alert("请选择一条记录进行提交");
								return false;
							}else if (ids.length > 1) {
								alert("请选择一条记录进行提交");
								return false;
							}else if(states!=1 && states!=5){
								alert("当前审核态不能提交");
								return false;
							}
							$.ajax({
								type : 'POST',
								url : "${ctx}/life/organizascore/organizeLifeTj/" + ids,
								type : "get",
								dataType : "json",
								async : false,//同步  
								success : function(result) {		
									if(result.type == "success"){						
										top.$.jBox.confirm("组织积分申请提交成功！","系统提示",function(v,h,f){
											if(v=="ok"){
											    window.location.reload();//刷新当前页面.
											}
										},{buttonsFocus:1});
										top.$('.jbox-body .jbox-icon').css('top','55px');
									} else {
										$.jBox.info("组织积分申请提交失败！");
									}
								}
							});
						} else {
							top.$.jBox.error("当前支部未开通！","系统提示",function(v,h,f){
							
							},{buttonsFocus:1});
							top.$('.jbox-body .jbox-icon').css('top','55px');
														
						}
					}
				});				

		});		
		//修改
		$("#btnUp").on('click', function() {
			
			$.ajax({
				type : 'POST',
				url : "${ctx}/life/organizeLife/checkOrgSatate",
				type : "get",
				dataType : "json",
				async : false,//同步  
				success : function(result) {		
					if(result.type == "success"){
						var ids = getCheckList();
						var states=getCheckListState();
						if (ids.length < 1) {
							alert("请选择一条记录修改");
							return false;
						}else if (ids.length > 1) {
							alert("请选择一条记录修改");
							return false;
						}else if(states!=1 && states!=5){
							alert("当前审核态不能修改");
							return false;
						}			
						$("#searchForm").attr("action","${ctx}/life/organizascore/form?id="+ids);
						$("#searchForm").submit();
					} else {
						top.$.jBox.error("当前支部未开通！","系统提示",function(v,h,f){
						
						},{buttonsFocus:1});
						top.$('.jbox-body .jbox-icon').css('top','55px');
													
					}
				}
			});	
		});		
	});
		function page(n, s) {
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
			return false;
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a>组织积分申请</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="organizeLife" action="${ctx}/life/organizascore/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
				<input type="hidden" name="ids" id="ids">
		
<ul class="ul-form">
            <li><label>活动名称：</label>
				<form:input path="lifename" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
		    <li><label style="margin-left: 20px;">开始时间：</label>
				<input style="width:150px" name="starttime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${organizeLife.starttime}" pattern="yyyy-MM-dd HH:mm"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
			</li>
			<li><label style="margin-left: 20px;">结束时间：</label>
				<input style="width:150px" name="endtime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${organizeLife.endtime}" pattern="yyyy-MM-dd HH:mm"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
			</li>
			
			
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="btns"><input id="btnAdd" class="btn btn-primary" type="button" value="新增"/></li>
			<li class="btns"><input id="btnUp" class="btn btn-primary" type="button" value="修改"/></li>
			<li class="btns"><input id="btnTj" class="btn btn-primary" type="button" value="提交"/></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			<th width="2%" style='text-align: center'><input
					type="checkBox" id="checkAll" /></th>
				<th style="width: 3px;">序号</th>
				<th style="width:35%">活动名称</th>
				<th style="width:15%">审核状态</th>
				<th style="width:15%">开始时间</th>
				<th style="width:15%">结束时间</th>
				<th style="width:15%">活动地点</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="organizeLife" varStatus="rowIndex">
			<tr>
			    <td style='text-align: center'><input type='checkbox' id='ids' name='ids' value='${organizeLife.id}' /></td>
					<td style='text-align: center'>${rowIndex.index+1}</td>
				<td><a href="${ctx}/life/organizascore/queryInfo?id=${organizeLife.id}">
					${organizeLife.lifename}</a>
				</td>		
				<td style='text-align: center'>
					${fns:getDictLabel(organizeLife.shstate, 'life_approve_status', '')}
					<input type='hidden' id='state' name='state' value='${organizeLife.shstate}' />
				</td>
				<td style='text-align: center'>
					<fmt:formatDate value="${organizeLife.starttime}" pattern="yyyy-MM-dd HH:mm"/>
				</td>
				<td style='text-align: center'>
					<fmt:formatDate value="${organizeLife.endtime}" pattern="yyyy-MM-dd HH:mm"/>
				</td>				
				<td>
					<div style="width:150px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;" 
					title="${organizeLife.adress}">${organizeLife.adress}</div>
				</td>
				
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>